<?php
C_base::yn_file('base'.DS.'htmlbase.php');
class main extends htmlbase
{
	var $_vpath = '';//pc/phone文件夹下的路径
	
	function __construct(){
		parent::__construct();
	}
	
	function gwty($w=array()){
		$r = array();
		for($i=0;$i<10;$i++){
			$r[$i] = C_base::M('admin.recruit')->qy_gw_ss($i,$w);
		}
		$rs = util::arr_one($r);
		if($rs){
			$rs = util::paixu($rs,'time','desc');//排序
			$rs = util::fenye($rs,1,5);//分页
		}
		return $rs;
	}
	
	function index(){//首页


		$this->title ='思凯';
		//公务员招聘5条
		$this->gwy = $this->gwty(array('style'=>2,'issue'=>1,'jstime>'=>time()));
		//企业招聘5条
		$this->qyzp = $this->gwty(array('style!'=>2,'zt'=>0,'issue'=>1,'jstime>'=>time()));
		//兼职招聘5条
		$this->jzzp = $this->gwty(array('style!'=>2,'zt'=>1,'issue'=>1,'jstime>'=>time()));
		
		if(@$this->Ses('recruit_uid') && (@$this->Ses('recruit_type') == 1)){
			$tj = C_base::M('admin.recruit')->tongji_s(array('uid'=>$this->Ses('recruit_uid')));
			//未读推荐文章
			$this->wdcount = @$tj['tuijian'];
			//共应聘职位数
			$this->ypcount = @$tj['toudi'];
		}
		
		if (@$this->Ses('firm_id') && (@$this->Ses('recruit_type') == '2')){
			$tj = C_base::M('admin.recruit')->qy_gw_tj_s(array('qid'=>$this->Ses('firm_id')));
			if (@$tj['wd']){
				$this->zx = $tj['wd'];
			}else {
				$this->zx = '0';
			}
			if (@$tj['yfb']){
				$this->yfb = $tj['yfb'];
			}else {
				$this->yfb = '0';
			}
		}
		
		if(@$this->Ses('recruit_zjid') && (@$this->Ses('recruit_type') == 3)){
			$zj = C_base::M('admin.recruit')->zjtongji_s(array('zjid'=>$this->Ses('recruit_zjid')));
			//最新投递简历
			$this->tdjl = @$zj['jlwds'];
			//正在招聘的职位
			$rr = C_base::con('html.job')->zwlx($this->Ses('recruit_zjid'));
			$this->zpzw = count(@$rr);
		}
		
		$this->news = C_base::M('kefu.news')->news_ssp(array('id!'=>0),1,10,'time','desc');
	}
	
/*********************************通用***************************************/
	function upfile(){//上传图片
		$this->title = '上传图片';
		$this->id = @$this->_get('id');//图片返回id
		$this->t = @$this->_get('type');//type=1单张图片,type=2多张图片累加
		$this->src = @$this->_get('src');//图片路径id
		$this->mc = @$this->_get('mc');
	}
	
	function uptp(){//上传图片
		$this->title = '上传图片';
		$this->id = @$this->_get('id');
		$this->t = @$this->_get('type');
		$this->src = @$this->_get('src');
		$this->mc = @$this->_get('mc');
		$this->tplj = C_base::dybase('util')->sctp('logo');
		$this->tpname = C_base::dybase('util')->tpname($this->tplj);
	}
	
	function get_diqu(){//获取地区---标签解析三级联动用到
		$id = $this->_post('id');
		$str = '<option value="0">请选择</option>';
		if($id != 0){
			$rs = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$id));
			if(@$rs){
				foreach ($rs as $k=>$v){
					$str .= '<option value="'.$v['area_id'].'">'.$v['area_name'].'</option>';
				}
			}
		}
		echo $str;
	}
	
	function get_diqus(){//获取地区---搜索用
		$id = $this->_post('id');
		$str = '<div class="f_l l_m10 active point" style="_margin-left:5px;">不限</div>
				<div class="f_l w_850 hid" id="content_1">';
		if($id != 0){
			$rs = C_base::M('admin.port')->linkage_ss(array('parent_id'=>$id));
			if(@$rs){
				$str = '<div class="f_l l_m10 active point" style="_margin-left:5px;" onclick=qbyc("qu",'.count($rs).')>不限</div>
						<div class="f_l w_850 hid" id="content_1">';
				foreach ($rs as $k=>$v){
					$str .= '<span id="qu'.$k.'" onclick=gbval("qu",'.$v['area_id'].','.$k.','.count($rs).')>'.$v['area_name'].'</span>';
				}
			}
		}
		$str .= '</div>
				<div class="jian point f_l l_m15" id="icon_1" style="display:none" onclick=change("icon_1","content_1")>
				</div>';
		echo $str;
	}
	
	function get_zhiwei(){//获取职位
		$id = $this->_post('id');
		$str = '<option value="0">请选择</option>';
		if($id != 0){
			$rs = C_base::M('admin.recruit')->job_ss(array('sid'=>$id));
			if(@$rs){
				foreach ($rs as $k=>$v){
					$str .= '<option value="'.$v['id'].'">'.$v['name'].'</option>';
				}
			}
		}
		echo $str;
	}
	
	function get_zhuanye(){//获取职位
		$id = $this->_post('id');
		$str = '<option value="0">请选择</option>';
		if($id != 0){
			$rs = C_base::M('admin.recruit')->major_ss(array('sid'=>$id));
			if(@$rs){
				foreach ($rs as $k=>$v){
					$str .= '<option value="'.$v['id'].'">'.$v['name'].'</option>';
				}
			}
		}
		echo $str;
	}

	//新闻列表
	function news(){
		extract($this->_get());
		$this->page = $page ? $page : 1;
		$this->pagesize = 10;
		$this->r = C_base::M('kefu.news')->news_ssp(array('id!'=>0),$this->page,$this->pagesize,'time','desc');
		$this->zpage = ceil($this->r['count']/$this->pagesize);
	}
	
	//新闻详情
	function newsxx(){
		extract($this->_get());
		$this->v = C_base::M('kefu.news')->news_s(array('id'=>$id));
		$this->v['content'] = htmlspecialchars_decode($this->v['content']);
		$this->nnew = C_base::M('kefu.news')->news_ssp(array('id!'=>0),1,5,'time','desc');
		$this->unew = C_base::M('kefu.news')->title_s(array('id<'=>$id),'desc');
		$this->dnew = C_base::M('kefu.news')->title_s(array('id>'=>$id));
	}
	
	//思凯简介
	function jianjie(){
		extract($this->_get());
		$this->title = '思凯简介';
		$this->type = @$type ? $type : 1;
		if($type == 1){
			$this->rs = C_base::M('public')->con_s(array('qyjj','zyyw','hzjh'));
			$this->rs['qyjj'] = htmlspecialchars_decode($this->rs['qyjj']);
			$this->rs['zyyw'] = htmlspecialchars_decode($this->rs['zyyw']);
			$this->rs['hzjh'] = htmlspecialchars_decode($this->rs['hzjh']);
		}elseif($type == 2){
			$this->rs = C_base::M('public')->con_s(array('phone','email','firm','address'));
			$this->rs['phone'] = htmlspecialchars_decode($this->rs['phone']);
			$this->rs['email'] = htmlspecialchars_decode($this->rs['email']);
			$this->rs['firm'] = htmlspecialchars_decode($this->rs['firm']);
			$this->rs['address'] = htmlspecialchars_decode($this->rs['address']);
		}elseif($type == 3){
			$this->rs = C_base::M('public')->con_s(array('fwsm'));
			$this->rs['fwsm'] = htmlspecialchars_decode($this->rs['fwsm']);
		}elseif($type == 4){
			$this->rs = C_base::M('public')->con_s(array('bzzx'));
			$this->rs['bzzx'] = htmlspecialchars_decode($this->rs['bzzx']);
		}
	}
/**************************************/
	//每天24:00执行一次
	function xt(){//系统执行事件
		$this->_is_html=1;
		C_base::con('kefu.tuisong')->dsts();
	}
/**************路由*********************/
	function job(){ //专家
		$this->_is_html=1;
		C_base::own('html.job');
	}
	
	function ruser(){//个人
		$this->_is_html=1;
		C_base::own('html.ruser');
	}
	
	function firm(){//企业
		$this->_is_html = 1;
		C_base::own('html.firm');
	}
	
}